package com.itheima.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class SockdetDemoGuangBo01 {
    public static void main(String[] args) throws IOException {
        //1.创建接受端DatagramSocket对象
        DatagramSocket da = new DatagramSocket();
        String S = "112R3";
        byte[] bytes = S.getBytes();
        //发送广播地址
        InetAddress name = InetAddress.getByName("255.255.255.255");
        int port = 8080;
        //数据打包
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, name, port);
        //调用对象发送
        da.send(dp);
        //释放
        da.close();
    }
}
